const bcrypt = require('bcrypt');

// 加密密码
async function hashPassword(password) {
 const saltRounds = 10; // 盐的轮数，越多越安全，但也越耗时
 const hashedPassword = await bcrypt.hash(password, saltRounds);
 return hashedPassword;
}

// 验证方法
async function checkPassword(password, hashedPassword) {
    const match = await bcrypt.compare(password, hashedPassword);
    return match; 
}
   
  
   

module.exports = {hashPassword,checkPassword}
